package com.lzh.gulimall.search.Controller;

import com.lzh.gulimall.search.service.MallSearchService;
import com.lzh.gulimall.search.vo.SearchParam;
import com.lzh.gulimall.search.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @ClassName SearchController
 * @Description TODO
 * @Author liuzhihui
 * @Date 2020/8/27 22:11
 * @Version 1.0
 **/
@Controller
public class SearchController {
    @Autowired
    private MallSearchService mallSearchService;

    @GetMapping(value = "/list.html")
    public String listPage(SearchParam searchParam, Model model){
        //根据传递来的页面的查询参数，去es中检索商品
        SearchResult searchResult=mallSearchService.search(searchParam);
        model.addAttribute("result",searchResult);
        return "list";
    }

}
